#pragma once

#include "BufferGL3x.h"
#include "VertexBuffer.h"

namespace Renderer
{
	namespace GL3x
	{
		
		class VertexBufferGL3x : public VertexBuffer
		{
		public:
			VertexBufferGL3x(const BufferHint& usageHint, int sizeInBytes)
			{
				_usageHint = usageHint;
				_sizeInBytes = sizeInBytes;
				_bufferObject = new BufferGL3x(BufferTarget::ArrayBuffer, usageHint, sizeInBytes);
			}

			void Bind()
			{
				_bufferObject->Bind();
			}

			void UnBind()
			{
				glBindBuffer(GL_ARRAY_BUFFER, 0);
			}

			template<typename T>
			void CopyFromSystemMemory(T* bufferInSystemMemory, int destinationOffsetInBytes, int lengthInBytes)
			{
				_bufferObject->CopyFromSystemMemory<T>(bufferInSystemMemory, destinationOffsetInBytes, lengthInBytes);
			}

			template<typename T>
			T* CopyToSystemMemory(int offsetInBytes, int sizeInBytes)
			{
				return _bufferObject->CopyToSystemMemory<T>(offsetInBytes, sizeInBytes);
			}


			int GetSizeInBytes()
			{
				return _bufferObject->GetSizeInBytes();
			}
			
			BufferHint GetUsageHint()
			{
				return (BufferHint)_usageHint;
			}

			void Destroy()
			{
				_bufferObject->Destroy();
			}

		private:
			BufferGL3x* _bufferObject;
		};
	}
}